* Paper: 深度智能化：后机器换人时代生产率增长的动力
* Author:Yongjin Wang, Wenbin Wang and Fei Chen   
* Date: Dec 1, 2024


clear

cd "/Users/wenbinwang/Documents/Working Paper/被忽视的深度智能化：实现生产率增长的新机遇/《世界经济》/校稿/Replication Files/Replication Files（深度智能化：后机器换人时代生产率增长的动力（稿号：2023011993））/Replication"

use "Data/final/Regression.dta",replace

capture log close
set logtype text
log using "Log/Regression.log", replace

global xlist "lnage lnage2 lnemployee lnimv_firm  lngdp lnpeople lncitywage cpi HHI indemployeeshare indsoeshare indfoeshare"

/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table 3 Basic Result

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */


reg TFP IM, cluster(firmid)
est store m1
reghdfe TFP IM,absorb(firmid year icode) cluster(firmid)
est store m2
reghdfe TFP IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m3
reg TFP Intensive_IM Extensive_IM,  cluster(firmid)
est store m4
reghdfe TFP Intensive_IM Extensive_IM,absorb(firmid year icode) cluster(firmid)
est store m5
reghdfe TFP Intensive_IM Extensive_IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m6
esttab m1 m2 m3 m4 m5 m6 using Output/RegressionTable/table03.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 


/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table 4 Endogenous analysis

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */
ivreghdfe TFP  (IM= IM_iv) $xlist , absorb(firmid year icode) cluster(firmid) 
est store m1
ivreghdfe TFP  (Intensive_IM Extensive_IM= Intensive_IM_iv Extensive_IM_iv) $xlist , absorb(firmid year icode) cluster(firmid) 
est store m2
esttab m1 m2  using Output/RegressionTable/table04.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 


/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table 5: hetrogentity 

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */


gen IMKL=IM*KL
gen Intensive_IMKL=Intensive_IM*KL
gen Extensive_IMKL=Extensive_IM*KL

gen IMThreshold=IM*Threshold
gen Intensive_IMThreshold=Intensive_IM*Threshold
gen Extensive_IMThreshold=Extensive_IM*Threshold

reghdfe TFP IMKL IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m1
reghdfe TFP Intensive_IMKL Extensive_IMKL  Intensive_IM Extensive_IM   $xlist ,absorb(firmid year icode) cluster(firmid)
est store m2

reghdfe TFP IMThreshold IM Threshold $xlist ,absorb(firmid year icode) cluster(firmid)
est store m3
reghdfe TFP Intensive_IMThreshold Extensive_IMThreshold Intensive_IM Extensive_IM   Threshold $xlist ,absorb(firmid year icode) cluster(firmid)
est store m4

esttab m1 m2 m3 m4 using Output/RegressionTable/table05.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 


/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table 6 chanel

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */
*Chanel1:patent
reghdfe Patent IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m1
reghdfe Patent Intensive_IM Extensive_IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m2

*Chanel2:capacity
reghdfe Capacity  IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m3
reghdfe Capacity Intensive_IM Extensive_IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m4

*Chanel3:distortion
reghdfe Labor_Distortion IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m5
reghdfe Labor_Distortion Intensive_IM Extensive_IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m6

esttab m1 m2 m3 m4 m5 m6 using Output/RegressionTable/table06.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 


/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table 7: distortion

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */
reghdfe Capital_Distortion IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m1
reghdfe Capital_Distortion Intensive_IM Extensive_IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m2
reghdfe Distortion IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m3
reghdfe Distortion Intensive_IM Extensive_IM  $xlist ,absorb(firmid year icode) cluster(firmid)
est store m4
esttab m1 m2 m3 m4 using Output/RegressionTable/table07.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 

  
/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table A2: Robustness check -- another IM and productivity cluster and simple 

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */

reghdfe TFP IM_dep $xlist ,absorb(firmid year icode) cluster(firmid)
est store m1

reghdfe TFP Intensive_dep Extensive_dep $xlist ,absorb(firmid year icode) cluster(firmid)
est store m2

reghdfe TFP_acf IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m3

reghdfe TFP_acf Intensive_IM Extensive_IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m4

reghdfe TFP IM $xlist ,absorb(firmid year icode) cluster(icode)
est store m5

reghdfe TFP Intensive_IM Extensive_IM $xlist ,absorb(firmid year icode) cluster(icode)
est store m6

esttab m1 m2 m3 m4 m5 m6 using Output/RegressionTable/tableA2.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 
 
 
/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Table A3: Robustness check -- lag and another fix effect 

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */

xtset firmid year

reghdfe TFP l.IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m1

reghdfe TFP l.Intensive_IM l.Extensive_IM $xlist ,absorb(firmid year icode) cluster(firmid)
est store m2

reghdfe TFP IM  $xlist if IM>0,absorb(firmid year icode ) cluster(firmid)
est store m3

reghdfe TFP Intensive_IM Extensive_IM $xlist if IM>0 ,absorb(firmid year icode ) cluster(firmid)
est store m4

reghdfe TFP IM  $xlist ,absorb(firmid year provincecode#year industry3#year) cluster(firmid)
est store m5

reghdfe TFP Intensive_IM Extensive_IM  $xlist ,absorb(firmid year provincecode#year industry3#year) cluster(firmid)
est store m6
esttab m1 m2 m3 m4 m5 m6 using Output/RegressionTable/tableA3.rtf, replace  b(%6.3f) nogap compress star( * 0.1 ** 0.05 *** 0.01) ar2 scalar(N year) 


log close
